package com.juc.completionService.completionService5;

import java.util.concurrent.CompletionService;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.Executors;

public class Run1 {

	/**
	 * 因为没有调用FutureTask类的get()方法 ,所以不会出异常
	 * @param args
	 * @throws InterruptedException
	 */
	public static void main(String[] args) throws InterruptedException {
		MyCallableA callableA = new MyCallableA();
		MyCallableB callableB = new MyCallableB();
		Executor executor= Executors.newSingleThreadExecutor();
	    CompletionService csRef = new ExecutorCompletionService<>(executor);
	    csRef.submit(callableA);
	    csRef.submit(callableB);
	    for (int i = 0; i < 2; i++) {
			System.out.println("zzzzzzzzzzzzz  " + csRef.take());
		}
	    System.out.println("main end!");
	}
}
